﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DAO
{
    public class ClubDao : BaseDao
    {
        public Club Club { get; set; }

        public List<Club> GetAllClub()
        {
            var query = from c in _agiltasticDbEntities.Club
                        orderby c.Name
                        select c;
            return query.ToList();
        }

        public Club GetById(int id)
        {
            var query = from c in _agiltasticDbEntities.Club
                        where c.Id == id
                        select c;
            return query.FirstOrDefault();
        }

        public void Update(Club currentSelected)
        {
            var Club = GetById(currentSelected.Id);
            Club.Name = currentSelected.Name;
            Club.Adress = currentSelected.Adress;
            Club.Email = currentSelected.Email;
            Club.WebSite = currentSelected.WebSite;
            _agiltasticDbEntities.SaveChanges();
        }

        public void Save(Club currentSelected)
        {
            _agiltasticDbEntities.Club.Add(currentSelected);
            _agiltasticDbEntities.SaveChanges();
        }
    }
}
